import { request } from '@umijs/max';
import { Constants } from '@/constants';
import qs from 'qs';

export async function update1(body: Record<string, any>, options?: { [key: string]: any }) {
  return request(Constants.baseURL + 'api/lottery/update1', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: qs.stringify(body),
    ...(options || {}),
  });
}

export async function result(body:Record<string, any>,options?: { [key: string]: any }) {
  return request(Constants.baseURL+'api/lottery/result', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: qs.stringify({
      ...body,
      pageNumber: body.current || 1,
      pageSize: 1000,
    }),
    ...(options || {}),
  }).then(result => ({
    success: true,
    data: result.data.content,
    total: result.data.total,
  }));
}
export async function remove(body:Record<string, any>,options?: { [key: string]: any }) {
  return request(Constants.baseURL+'api/lottery/remove', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: qs.stringify(body),
    ...(options || {}),
  });
}
